package com.looso.sfolder.ui;

import com.looso.sfolder.R;
import com.looso.sfolder.data.UserInfo;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;

public class SettingActivity extends Activity{
	
	private EditText mIpEditText = null;
	private EditText mPortEditText = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.settings);
		
		initView();
	}

	private void initView() {
		mIpEditText = (EditText) findViewById(R.id.setting_ip);
		String ip = UserInfo.getInstance().getIp();
		mIpEditText.setText(ip);
		
		mPortEditText = (EditText) findViewById(R.id.setting_port);
		String port = UserInfo.getInstance().getPort();
		mPortEditText.setText(port);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode==KeyEvent.KEYCODE_BACK){
			String ip = mIpEditText.getText().toString();
			UserInfo.getInstance().setIp(ip);
			
			String port = mPortEditText.getText().toString();
			UserInfo.getInstance().setPort(port);
			
			finish();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
}




